options {
    STATIC = false;
}

PARSER_BEGIN(Parser)
import java.io.*;

class Parser {
    
    static public AST parseFile(File file
				// LibraryLoader loader,
                                // ErrorHandler errorHandler
				)
	throws SyntaxException, FileException {
	
        return parseFile(file, 
			 // loader, 
			 // errorHandler, 
			 false);
    }

    // #@@range/parseFile{
    static public AST parseFile(File file, 
				// LibraryLoader loader,
                                // ErrorHandler errorHandler, 
				boolean debug)
                                throws SyntaxException, FileException {
        return newFileParser(file, 
			     // loader, 
			     // errorHandler, 
			     debug).parse();
    }
    // #@@}
    
    static final public String SOURCE_ENCODING = "UTF-8";

    static public Parser newFileParser(File file,
				       // LibraryLoader loader,
				       // ErrorHandler errorHandler,
				       boolean debug)
	throws FileException {
	try {
	    BufferedReader r =
		new BufferedReader(
				   new InputStreamReader(
							 new FileInputStream(file),
							 SOURCE_ENCODING));
	    return new Parser(r, file.getPath(), 
			      //loader, errorHandler, 
			      debug);
	}
	catch (FileNotFoundException ex) {
	    throw new FileException(ex.getMessage());
      }
	catch (UnsupportedEncodingException ex) {
	    throw new Error("UTF-8 is not supported??: " + ex.getMessage());
	}
    }
    // #@@}

    // #@@range/ctor1{
    public Parser(Reader s, String name
                  // LibraryLoader loader, ErrorHandler errorHandler
		  ) {
        this(s, name, 
	     // loader, errorHandler, 
	     false);
    }
    // #@@}

    // #@@range/ctor2{
    public Parser(Reader s, String name,
		  // LibraryLoader loader, ErrorHandler errorHandler, 
		  boolean debug) {
        this(s);
        // this.sourceName = name;
        // this.loader = loader;
        // this.errorHandler = errorHandler;
        // this.knownTypedefs = new HashSet<String>();
        if (debug) {
            enable_tracing();
        }
        else {
            disable_tracing();
        }
    }
    // #@@}

    public AST parse() { // throws SyntaxException {
        
	return new AST(); //compilation_unit();
      
    }

    static public long evaluate(String src) 
	throws ParseException 
    {
	Reader reader = new StringReader(src);
	return new Parser(reader).expr();
    }
}
PARSER_END(Parser)

SKIP: { <[" ", "\t", "\r", "\n"]> }

TOKEN: {
    <INTEGER: (["0"-"9"])+>
}

long expr():
{
    Token x, y;
}
{
    x=<INTEGER> "+" y=<INTEGER> <EOF>
	{	    
	    return 
	    Long.parseLong(x.image) + 
	    Long.parseLong(y.image);
	}
}
